package com.vcms.cms.service.impl;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;

import com.vcms.cms.dao.HibernateDaoSupport;
import com.vcms.cms.service.BasicService;
import com.vcms.common.util.PageBean;

public abstract class BasicServiceImpl<T> implements BasicService<T> {

	private HibernateDaoSupport<T> hibernateDaoSupport;

	@Override
	public void save(T transientInstance) {
		hibernateDaoSupport.save(transientInstance);
	}

	@Override
	public void update(T transientInstance) {
		hibernateDaoSupport.update(transientInstance);
	}

	@Override
	public void delete(int id) {
		hibernateDaoSupport.delete(id);
	}

	@Override
	public void delete(T transientInstance) {
		hibernateDaoSupport.delete(transientInstance);
	}

	@Override
	public void saveOrUpdate(T transientInstance) {
		hibernateDaoSupport.saveOrUpdate(transientInstance);
	}

	@Override
	public T findById(Integer id) {
		return hibernateDaoSupport.findById(id);
	}

	@Override
	public T findByUniqueProperty(String propertyName, Object value) {
		return hibernateDaoSupport.findByUniqueProperty(propertyName, value);
	}

	@Override
	public Collection<T> findByProperty(String propertyName, Object value) {
		return hibernateDaoSupport.findByProperty(propertyName, value);
	}

	@Override
	public Collection<T> searchByProperty(String propertyName, Object value) {
		return hibernateDaoSupport.searchByProperty(propertyName, value);
	}

	@Override
	public Collection<T> findAll() {
		return hibernateDaoSupport.findAll();
	}

	@Override
	public long getAmount() {
		return hibernateDaoSupport.getAmount();
	}

	@Override
	public long getAmount(String propertyName, Object value) {
		return hibernateDaoSupport.getAmount(propertyName, value);
	}

	@Override
	public Collection<T> findByPage(PageBean pageBean) {
		return hibernateDaoSupport.findByPage(pageBean);
	}

	@Override
	public Collection<T> findByPage(Boolean increase, String orderpropertyName,
			PageBean pageBean) {
		return hibernateDaoSupport.findByPage(increase, orderpropertyName,
				pageBean);
	}

	@Override
	public Collection<T> findByPage(String propertyName, Object value,
			PageBean pageBean) {
		return hibernateDaoSupport.findByPage(propertyName, value, pageBean);
	}

	@Override
	public Collection<T> findByPage(String propertyName, Object value,
			Boolean increase, String orderpropertyName, PageBean pageBean) {
		return hibernateDaoSupport.findByPage(propertyName, value, increase,
				orderpropertyName, pageBean);
	}

	@Override
	public Collection<T> findByPage(String propertyName, Object value,
			PageBean pageBean, Boolean fuzzy) {
		return hibernateDaoSupport.findByPage(propertyName, value, pageBean,
				fuzzy);
	}

	public HibernateDaoSupport<T> getHibernateDaoSupport() {
		return hibernateDaoSupport;
	}

	@Autowired
	public void setHibernateDaoSupport(
			HibernateDaoSupport<T> hibernateDaoSupport) {
		this.hibernateDaoSupport = hibernateDaoSupport;
	}

}
